{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" >
                            <input type="text" class="layui-input search" name="school" value="" placeholder="学校名字|学校标识"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" >
                            <input type="text" class="layui-input search" name="school2" value="" placeholder="衣服款号"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" >
                            <input type="text" class="layui-input search" name="typename" value="" placeholder="衣服分类"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" >
                            <input type="text" class="layui-input search" name="year" value="" placeholder="年份"/>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="status" class="layui-input">
                                <option value="">所有状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <input type="text"  name="start" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="更新时间-起" />
                        </div>
                        <div class="layui-input-inline layui-form">
                            <input type="text"  name="end" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="更新时间-止" />
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group">
                        <button class="btn btn-warning" type="button" onclick="wk.layer_show('冻结', '{:url('goDong')}')" style="margin-right: 20px">
                             去冻结
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('excelIn2')}');">
                            <i class="fa fa-file-excel-o"></i> 产品包新增
                        </button>
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出数据 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-print"></i>导出</a></li>
                        </ul>
                    </div>
                </div>

                <!--操作框结束-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <script type="text/html" id="sexsex">
                        {{# if(d.sg_sex == 1){ }}
                        男
                        {{# } }}
                        {{# if(d.sg_sex == 2){ }}
                        女
                        {{# } }}
                    </script>
                    <script type="text/html" id="staBar2">
                        <input type="checkbox" value="{{d.sg_id}}"  lay-skin="switch"  lay-text="正常|冻结" lay-filter="OnOff2" {{ d.sg_status == 1 ? 'checked' : '' }}  >
                    </script>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.good_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.confirm('{{d.sg_id}}','{:url('sgDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o">删除</i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Product/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'sg_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'school_name', width: '', title: '学校名称', align: 'center'}
                , {field: 'sg_school_erp', width: '', title: '学校标识', align: 'center'}
                , {field: 'good_name', width: '', title: '校服名字', align: 'center'}
                , {field: 'good_type', width: '', title: '分类', align: 'center'}
                , {field: 'sg_good_coding', width: '', title: '校服标识', align: 'center'}
                , {field: 'good_thumb', width: '', title: '校服图', align: 'center', templet: '#imgTpl'}
                , {field: 'sg_sign', width: '', title: '校标', align: 'center', edit: 'test'}
                , {field: 'sg_year', width: '', title: '年份', align: 'center'}
                , {field: 'sg_sex', width: '', title: '性别', align: 'center', templet: '#sexsex'}
                , {field: 'good_price', width: '', title: '价格', align: 'center'}
                , {field: 'sg_time', width: '', title: '上传时间', align: 'center'}
                , {field: 'sg_updatetime', width: '', title: '更新时间', align: 'center'}
                , {field: 'sg_status',fixed: 'right', width: '', title: '是否冻结', align: 'center', templet: '#staBar2'}
               , {fixed: 'right', width: 100, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听单元格编辑---改校标
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.sg_id,"{:url('updateSign')}",field,value);
        });
        form.on('switch(OnOff2)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeSgStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutPro')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</body>
</html>